package great.project.common;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Random;
import java.util.UUID;
import java.util.regex.Pattern;

/**
 * 常量类
 *
 * @author zhangshun
 */
public interface Constants {

    interface Redis {

    }


    interface Regex {

        /**
         * 邮箱正则表达式
         */
        Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");

    }

    interface Date {

        /**
         * 当的时间戳
         *
         * @return 时间戳
         */
        static Long nowTimestamp() {
            return System.currentTimeMillis();
        }


        /**
         * 默认时间格式
         */
        String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
        /**
         * 默认的 DateTimeFormatter
         */
        DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_DATE_PATTERN);

        /**
         * 默认的 SimpleDateFormat
         *
         * @return SimpleDateFormat
         */
        static SimpleDateFormat defaultSimpleDateFormat() {
            return new SimpleDateFormat(DEFAULT_DATE_PATTERN);
        }

        static String defaultFormatTimestamp(Long timestamp){
            return defaultSimpleDateFormat().format(new java.util.Date(timestamp));
        }

    }

    Random RANDOM = new Random();

    /**
     * uuid
     *
     * @return 随机uuid
     */
    static String uuid() {
        return UUID.randomUUID().toString().replace("-", "");
    }

}
